import 'package:cat_eye/base/base_refresh_view_model.dart';
import 'package:cat_eye/base/base_view_model.dart';
import 'package:cat_eye/bean/sq_lite_bean.dart';
import 'package:cat_eye/sqflite/sqLite_manager.dart';
import 'package:cat_eye/util/loading_state_widget_util.dart';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

/*
* @Package: view_model
* @ClassName: other_myattention_view_model
* @Author: szj
* @CreateDate: 8/3/21 5:07 PM
* TODO 我的关注Video 其他数据
*/
class OtherMyAttentionViewModel extends BaseViewModel {
  List<SqLiteBean> sqList = [];

  String videoUrl;

  OtherMyAttentionViewModel(this.videoUrl);

  @override
  void refresh() async {
    //当下一个接口请求回来时候,关闭刷新按钮
    type = LoadingWidget.DONG;

    List<SqLiteBean> list = [];

    //遍历所有数据[不添加当前播放的视频]
    await SQLiteManager.getInstance().queryAllData()
      ..forEach((element) {
        if (element.videoUrl != videoUrl) {
          list.add(element);
        }
      });

    //反转
    sqList.addAll(list.reversed);

    notifyListeners();
  }

  //以下是网络请求的,不使用这个！！
  @override
  // TODO: implement httpUrl
  String get httpUrl => throw UnimplementedError();

  @override
  void successJsonData(json) {
    // TODO: implement successJsonData
  }
}
